package com.woniuxy.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.admin.entity.ResourseRole;
import com.woniuxy.admin.mapper.ResourseRoleMapper;
import com.woniuxy.admin.service.ResourseRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ...
 * @since 2024年05月22日
 */
@Service
public class ResourseRoleServiceImpl extends ServiceImpl<ResourseRoleMapper, ResourseRole> implements ResourseRoleService {

    @Override
    public List<Integer> selectResourseIdByRoleId(Integer roleId) {

        List<ResourseRole> resourseRoles = this.list(new QueryWrapper<ResourseRole>().eq("role_id", roleId));
        if(resourseRoles!=null&&resourseRoles.size()!=0) {
            List<Integer> resourseIds = resourseRoles.stream().map(r -> r.getResourseId()).collect(Collectors.toList());
            return resourseIds;
        }
        return null;
    }
}
